import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToMany,
  JoinTable,
} from "typeorm"
import { Photo } from "./Photo"

@Entity()
export class Album {
  @PrimaryGeneratedColumn()
  id: number

  @Column({ name: 'name' })
  name: string

  @ManyToMany(() => Photo, (photo) => photo.albums)
  @JoinTable({
    name: 'album_photos_relation', joinColumn: {
      name: 'album_id',
      referencedColumnName: 'id'
    }, inverseJoinColumn: {
      name: 'photo_id',
      referencedColumnName: 'id'
    }
  })
  photos: Photo[]
}